<template>
	<view :style="{
	fontSize:baseFSZ/20+'vw!important'
		}" v-if=currentinfo.Question_SAQ_Model>
		<view style="display: flex;align-items: center;border-bottom: 2rpx solid #e9e9e9;margin-top: 1vh;">
			<view  >
				<view   style="width: 100%;display: flex;justify-content: center;font-weight: bolder;" :style="{
	fontSize:baseFSZ/18+'vw!important'
		}">
					{{currentinfo.Question_SAQ_Model.Title}}
				</view>
				<view   style="margin: 2vh 0;">
					<text
						style="font-weight: bolder">[{{currentinfo.Question_SAQ_Model.ContentTitle}}]</text>({{currentinfo.Score}}分){{currentinfo.Question_SAQ_Model.ReadingContent}}


				</view>
				<view  
					style="display: flex;align-items: center;justify-content: space-between; width: 100%;padding:0vw;box-sizing: border-box;margin: 1vh 0;">
					<view v-if="currentinfo.Question_SAQ_Model.FilePath" @click="previewPdf(currentinfo.Question_SAQ_Model.FilePath)"
						style="font-weight: bolder;color:blue;display: flex;justify-content: flex-end;">[文件预览]</view>
					<view style="display: flex;width:6vw; align-items: center;justify-content: space-between;">
<!-- 						<u-icon @click="collect()" name="star" :color="IsCollect?'red':'#5d9cec'" size="28"></u-icon>
						<u-icon :name="isNoVoice?'volume-off':'volume' "
							@click="speak(currentinfo.Question_SAQ_Model.ContentTitle+currentinfo.Question_SAQ_Model.ReadingContent)"
							color="#5d9cec" size="28"></u-icon> -->

	<image v-if="IsCollect"  src="../static/hsc.png" @click="collect()"  style="width: 26px;height: 26px;flex-shrink: 0;" mode=""></image>
				<image v-else  src="../static/unsc.png" @click="collect()"  style="width: 26px;height: 26px;flex-shrink: 0;" mode=""></image>
		
		<image v-if="!isNoVoice" @click="speak(currentinfo.Question_SAQ_Model.ContentTitle+currentinfo.Question_SAQ_Model.ReadingContent)" src="../static/bf.png"  style="width: 26px;height: 26px;flex-shrink: 0;" mode=""></image>
				<image v-else @click="speak(currentinfo.Question_SAQ_Model.ContentTitle+currentinfo.Question_SAQ_Model.ReadingContent)" src="../static/jy.png"  style="width: 26px;height: 26px;flex-shrink: 0;" mode=""></image>
					</view>

				</view>

				<view   v-for="e in currentinfo.SAQ_Items">
					<view>{{e.SAQDetail.QuestionContent}}({{e.TotalScore}}分)</view>
					<view style="display: flex;justify-content: flex-end;">
						<!-- <image @click="collect()" :src="IsCollect?'../static/ysc.png':'../static/wsc.png'"  style="width: 24px;height: 24px;" mode=""></image> -->
						
						
						<image v-if="!isNoVoice" @click="speak(e.SAQDetail.QuestionContent)" src="../static/bf.png"  style="width: 26px;height: 26px;flex-shrink: 0;" mode=""></image>
								<image v-else @click="speak(e.SAQDetail.QuestionContent)" src="../static/jy.png"  style="width: 26px;height: 26px;flex-shrink: 0;" mode=""></image>
						
	<!-- 					<image @click="speak(e.SAQDetail.QuestionContent)" :src="isNoVoice?'../static/jy.png':'../static/bf.png'"  style="width: 24px;height: 24px;" mode=""></image> -->
						
				<!-- 		<u-icon :name="isNoVoice?'volume-off':'volume' "
							@click="speak(e.SAQDetail.QuestionContent)" color="#5d9cec" size="28"></u-icon> -->
							</view>
					<view   style="margin: 2vh 0;">
						<u--textarea @input="debouncedAnswerInput(e)" v-model="e.AnswerContent" :maxlength='-1' placeholder="请点击此处输入内容" autoHeight
							style="min-height: 20vh;"></u--textarea>
					</view>
					<view   style="margin: 2vh 0;">
						<u-button text="提交" @click="handleSubmit(e)" color="#556b8d" style="width: 4vw;margin: 0 auto;"
							size="small"></u-button>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		UpdateAnswer,
		Collect
	} from "../api/api.js"

	import {debounce} from "../utils/common.js"

	export default {
		name: "jdt",
		props: ['baseFSZ', 'currentinfo','isNoVoice'],
		data() {
			return {
				IsCollect: false
			};
		},
		created() {
			this.IsCollect = this.currentinfo.IsCollect
			this.debouncedAnswerInput = debounce(this.handleInput, 500);
		},
		mounted() {
			// let index = this.currentinfo.OptionList&&this.currentinfo.OptionList.findIndex(e => e.IsCheck)
			// if (index != -1) {
			// 	this.chooseIndex = index
			// 	this.chooseId = this.currentinfo.OptionList[index].Id
			// 	console.log(index, this.chooseId)
			// }

		},
		methods: {
		handleInput(es){
			this.handleSubmit(es)
		},
			handleSubmit(e) {
				UpdateAnswer(e.Id, e.AnswerContent).then(res => {
	
				})
			},

			previewPdf(url) {
				let nurl = url.replace(/\.\.\/\.\.\//,`http://${uni.getStorageSync('config').ip}:${uni.getStorageSync('config').port}` + '/')

				uni.navigateTo({ //保留当前页面，跳转到应用内的某个页面
					url: '/pages/webv/webv?url=' + nurl //带参跳转
				})
			},

			collect() {
				this.IsCollect = !this.IsCollect

				Collect(this.currentinfo.Id, this.IsCollect).then(res => {

				this.$emit('collect',this.IsCollect)
				})
			},
			speak(text) {

				// #ifdef APP-PLUS


				this.$emit('speaker', text)

				// #endif


			}

		}
	}
</script>

<style lang="scss">
	.normal {
		width: 1.6vw;
		height: 1.6vw;
		border-radius: 50%;
		border: 1px solid #bababa;
		position: relative;
		display: flex;
		align-items: center;
		margin-right: 1.6vw;
		justify-content: center;
		flex-shrink: 0;

		.ac {
			flex-shrink: 0;
			width: 1vw;
			height: 1vw;
			border-radius: 50%;
			background: #0075ff;

		}
	}
</style>